<%@page import="com.situ.web.entity.Student"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/Java1812Web/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />

</head>
<body>
<%
		List<Student> list = (List<Student>)request.getAttribute("list");
	%>
	<div class="container">
	<a class="btn btn-success" href="<%=request.getContextPath()%>/addStudent.html">添加</a>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th>编号</th>
			<th>姓名</th>
			<th>年龄</th>
			<th>性别</th>
			<th>删除</th>
			<th>修改</th>
		</tr>
		<%
			for (Student student : list) {
		%>
				<tr>
					<td><%=student.getId()%></td>
					<td><%=student.getName()%></td>
					<td><%=student.getAge()%></td>
					<td><%=student.getGender()%></td>
					<%-- <td><a href="/Java1812Web/deleteStudent?id=<%=student.getId()%>">删除</a></td> --%>
					<!--下面的这个href是防止他的刷新  -->
					<td><a href="javascript:void(0)" onclick="deleteById(<%=student.getId()%>)">删除</a></td>
					<td><a href="<%=request.getContextPath()%>/updateStudent?method=toUpdate&id=<%=student.getId()%>">修改</a></td>	
				</tr>
		<%
			}
		%>
	</table>
	</div>
	<script type="text/javascript">
			function deleteById(id){
				//用户点击确定，confirm返回的是true
				//用户点击取消，confirm返回的是false
				var isDel = confirm("您确定要删除么？");
				if (isDel) {
					location.href = "/Java1812Web/deleteStudent?id=" + id;
				}
			}
		</script>

</body>
</html>